﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Data.DataAccess.Database
{
    public class DbWorkspaceAccess
    {
        protected string str_connection_string;

        public DbWorkspaceAccess(string str_connection_string)
        {
            this.str_connection_string = str_connection_string;
        }

        public void AddWorkspace(WORKSPACE oWorkspace)
        {
            TfsPendingCheckinDataContext oTFS = new TfsPendingCheckinDataContext(str_connection_string);

            oTFS.WORKSPACEs.InsertOnSubmit(oWorkspace);

            oTFS.SubmitChanges();
        }

        public WORKSPACE GetWorkspace(int int_user_id, string str_name, string str_computer_name)
        {
            TfsPendingCheckinDataContext oTFS = new TfsPendingCheckinDataContext(str_connection_string);

            WORKSPACE oWorkspace = oTFS.WORKSPACEs.SingleOrDefault(workspace => workspace.USER_ID == int_user_id && workspace.WORKSPACE_NAME == str_name && workspace.WORKSPACE_COMPUTER == str_computer_name);

            return oWorkspace;
        }
    }
}
